package StudentManagement;

public class Student {


    private String studentId;
    private String name;
    private String major;
    private double score;
    private int age;

    public Student() {
        this.studentId = "未知";
        this.name = "未知";
    }
    public Student(String studentId, String name) {
        this.studentId = studentId;
        this.name = name;
    }


    public Student(String studentId, String name, String major) {
        this.studentId = studentId;
        this.name = name;
        this.major = major;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMajor() {
        return major;
    }

    public void setMajor(String major) {
        this.major = major;
    }
    public int getAge(){return age;}
    public void setAge(int age) {
        if (age >= 0 && age <= 100) {
            this.age = age;
        } else {
            System.out.println("年龄不合法（必须0~100分）");
        }
    }

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        if (score >= 0 && score <= 100) {
            this.score = score;
        } else {
            System.out.println("成绩不合法（必须0~100分）");
        }
    }

    public void showInfo() {
        System.out.println("学号: " + studentId + ",姓名: " + name + ",专业: " + major + ",成绩" + score + "分");
    }


}

